package top.malaoshi.service;

import org.springframework.stereotype.Service;
import top.malaoshi.entity.UserModel;
import top.malaoshi.mapper.IUserMapper;
import top.malaoshi.model.Result;

import javax.annotation.Resource;

import java.util.List;


@Service
public class ChangeSrvImpl {

    @Resource
    private IUserMapper dao;

    public Result change(String password, String newpassword, String phone){
        System.out.println("RegSrvImpl"+password+newpassword+phone);

        List<UserModel> list=dao.queryByPhoneAndPassword(phone,password);
        Result res=new Result();
        if(list.size()==0){
            UserModel um=new UserModel();
            um.setPhone(phone);
            um.setPassword(newpassword);
            dao.updateByPhone(um);
            //0表示可以修改
            res.setCode(0);
            //res.setMsg("可以修改");
        }else{
            //101表示没有该用户
            res.setCode(101);
            //res.setMsg("没有这个手机号啊，你在想什么？");
        }
        return res;

    }
}

